package com.dw.example;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;

public abstract class BaseActivity extends Activity {
  private static final String TAG = "BaseActivity";

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    
    String className = getClass().getName();
    String layoutName = className.substring(className.lastIndexOf(".") + 1).toLowerCase();
    int layoutId = getResources().getIdentifier(layoutName, "layout", getPackageName());
    setContentView(layoutId);
    
    initView();
    initData();
    registListener();
  }
  
  protected abstract void initView();
  
  protected abstract void initData();
  
  protected abstract void registListener();
  
  protected void showMessage(String message){
    Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
  }
}
